package cn.elwy.rcp.ui.explorer.core;

public class JarNameUtil {

  private static String reg = "[0-9-._]*(?i)(SNAPSHOT|jar)";

  public static String getName(String name) {
    if (name != null) {
      return name.replaceAll(reg, "");
    }
    return "";
  }

  public static void main(String[] args) {
    System.out.println(getName("cml-api-1.0.0.jar"));
    System.out.println(getName("cml-api-1.0.0-SNAPSHOT.jar"));
    System.out.println(getName("cml_api-1.0.0-20160219.jar"));
    System.out.println(getName("cml-api-1.0.0_SNAPSHOT.jar"));
    System.out.println(getName("cml-api_1.0.0.jar"));
    System.out.println(getName("cml-api-1.0.0_20160219.jar"));
    System.out.println(getName("com-yss-sofa-api-1.0.0.jar"));
    System.out.println(getName("com-yss-sofa-api-1.0.0-SNAPSHOT.jar"));
    System.out.println(getName("com-yss-sofa-api-1.0.0-20160219.jar"));
    System.out.println(getName("com_yss_sofa_api-1.0.0_SNAPSHOT.jar"));
    System.out.println(getName("com_yss-sofa-api_1.0.0.jar"));
    System.out.println(getName("com-yss_sofa-api-1.0.0_20160219.jar"));
  }
}
